import unittest

from Autotests.BaseTest import BaseTestCase
from Autotests.Cloud.Clients import FinancialService
from Autotests.Cloud.executor import ActionExecutor


class GrowersDecliners(BaseTestCase):
    def test_GrowersDecliners(self):
        executor = ActionExecutor()
        finserv = FinancialService()

        result = executor.enumeratePartners( executor.getPartnerInfo('IASO'), True)

        def GetGrowersDeclinersReport(partnerId):
            r = finserv.createObject('GetGrowersDeclinersReportRequest')
            r.partnerId = partnerId
            r.currency = 'EUR'
            r.countRecords = 25 # Top 25
            r.responsibleUserId = 0 # All users
            r.groupMode = 'NotGrouped'
            r.lastContactDays = 180
            r.regionId = 0 # All regions

            finserv.call('GetGrowersDeclinersReport', r)

        for p in result.partnerInfo:
            GetGrowersDeclinersReport(int(p.id))

if __name__ == "__main__":
    unittest.main()
